/**
 * @author maulin
 */
document.write ("you are using dojo: " + dojo.version + "<br />");
dojo.require("dojo.DeferredList");

document.write("the first thing you should see is callback1 getting called with content = CONTENT <br />");

var def = new dojo.Deferred();
def.addCallback(function(content) {
	document.write("callback: 1, content:" + content + "<br />");
	return content + "1";
})
def.callback("CONTENT");

document.write("the next thing you should see is callback2 getting called with content = CONTENT1 <br />");

def.addCallback(function(content) {
	document.write("callback: 2, content:" + content + "<br />");
	return content + "2";
});

document.write("next, prove that a deferred list will give you the content (content12), but won't let you change the content<br />");

var def2 = new dojo.DeferredList([def]);
def2.addCallback(function(content) {
    document.write("callback:3, content:" + content + "<br />");
    return "SHOULD NEVER SEE THIS";
})

document.write("next, show callback4 with unchanged content (CONTENT12), despite callback3 changing it<br />");


def.addCallback(function(content) {
    document.write("callback:4, content:" + content + "<br />");
    return content + "3";
});